package carol.pvp.analyzer.java.impl;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import carol.pvp.analyzer.impl.CodeTypeChecker;
import carol.pvp.analyzer.java.pattern.JavaCheckerPattern;

/**
 * 
 * @author carol
 *
 */
public class JavaCodeTypeChecker extends CodeTypeChecker{
	private boolean isCheckedType = false;
	
	protected boolean checkPackage(String code){
		isCheckedType = false;
		
        Pattern pattern = Pattern.compile(JavaCheckerPattern.PACKAGE_PATTERN);
        Matcher matcher = pattern.matcher(code);   
        if(matcher.find()){
        	isCheckedType = true;   
        }
		return isCheckedType;
	}
	
	protected boolean checkClass(String code){
		isCheckedType = false;
		
        Pattern pattern = Pattern.compile(JavaCheckerPattern.CLASS_PATTERN);
        Matcher matcher = pattern.matcher(code);
        if(matcher.find()){
        	isCheckedType = true;   
        }  
		return isCheckedType;
	}
	
	protected boolean checkMethod(String code){
		isCheckedType = false;
		
		Pattern pattern = Pattern.compile(JavaCheckerPattern.METHOD_PATTERN);
        Matcher matcher = pattern.matcher(code);
        if(matcher.find())  {
        	isCheckedType = true;   
        }
		return isCheckedType;
	}
	
}
